package com.youxin.busfoundation.config;

import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

/**
 * Mysql 监控配置
 * @author yingde.cao
 *
 */
@Configuration
@PropertySource("classpath:${spring.profiles.active}/monitor.properties")
@ConfigurationProperties(prefix="monitor.mysql")
public class MonitorMysqlConfig extends MonitorBaseBean{
	
	private List<DriverManagerDataSource> datasources;

	public List<DriverManagerDataSource> getDatasources() {
		return datasources;
	}
	public void setDatasources(List<DriverManagerDataSource> datasources) {
		this.datasources = datasources;
	}
	
	private static MonitorMysqlConfig config;
	private static Object lockObj=new Object();
	/**
	 * 程序启动时加载mysql monitor的配置
	 * @param mysqlConfig
	 */
	public static void initConfig(MonitorMysqlConfig mysqlConfig)
	{
		synchronized (lockObj) {
			if(config==null)
			{
				config=mysqlConfig;
			}
		}
	}
}
